package com.cscec5b.inspection.dto;

import jakarta.validation.Valid;
import jakarta.validation.constraints.*;
import java.util.List;

public class TaskInboundDtos {

    // 子项（写入 detail_inspection_original）
    public static class InspectItem {
        @NotNull public Integer task_item_id;
        @NotBlank public String fail_resample;   // "0"新任务，"1"重新采集
        @NotNull public Integer inspect_item_id;
        @NotBlank public String inspect_name;
        @NotNull @Size(min=1) public List<@NotBlank String> members; // 成员编号列表
        @NotNull public Integer data_type;
    }

    // 任务主项（写入 tasks）
    public static class TaskItem {
        @NotNull public Integer task_id;
        @NotBlank public String project_inner_number;
        @NotBlank public String subproject_name;
        @NotBlank public String inspect_rule;
        @NotBlank public String inspect_type;       // 中文 -> 英文，存 tasks.task_type
        @NotBlank public String inspect_batch_part; // -> tasks.location
        @NotNull  public Object  inspect_batch_volume; // list/object，转 JSON 存 tasks.task_volume
        @NotNull  public Object  design_values;        // json，转 JSON 存 tasks.design_values
        @NotNull @Size(min=1) @Valid public List<InspectItem> inspect_items;
    }

    // 整体请求
    public static class TaskInboundRequest {
        @NotNull @Size(min=1) @Valid public List<TaskItem> data;
    }

    // 响应
    public static class InspectItemResult {
        public Integer task_item_id;
        public boolean is_success;
        public String error;
        public InspectItemResult(Integer id, boolean ok, String err){ this.task_item_id=id; this.is_success=ok; this.error=err; }
    }
    public static class TaskResult {
        public Integer task_id;
        public boolean is_success;
        public List<InspectItemResult> inspect_items;
        public TaskResult(Integer id, boolean ok, List<InspectItemResult> items){ this.task_id=id; this.is_success=ok; this.inspect_items=items; }
    }
    public static class TaskInboundResponse {
        public String code="200";
        public String msg="请求成功";
        public List<TaskResult> detail;
        public TaskInboundResponse(List<TaskResult> d){ this.detail=d; }
    }
}
